package com.demo.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.fastjson.JSON;
import com.demo.model.UserContext;
import com.demo.service.MangerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * MangerController
 *
 * @author liujin
 * @date 2020/11/4 14:34
 */
@RefreshScope
@RestController
public class MangerController {

    @Autowired
    private MangerService mangerService;

    @Value("${myinfo.name}")
    private String name;

    @GetMapping("/mangers")
    public String manger(String msg) {

        System.out.println(UserContext.getUser());
        System.out.println(msg);
        mangerService.hello(msg);

        return JSON.toJSONString(msg);
    }

    @GetMapping("/sentinel")
    @SentinelResource("SentinelResource_sentinel")
    public String sentinel() {


        return "sentinel";
    }
}
